package com.gm.wholesale.module.config;

import com.gm.wholesale.module.config.bean.ConfigBean;

public class ConfigData {
    private static ConfigData configData=new ConfigData();
    private static ConfigBean sConfigBean;
    public static  ConfigData getConfigData(){
        return configData;
    }
    private ConfigData(){

    }


    public  void  setConfigBean(ConfigBean configBean) {
        sConfigBean = configBean;
    }

    public  ConfigBean getConfigBean() {
        return sConfigBean;
    }

    public  void clean() {
        sConfigBean = null;
    }

    public boolean hasCreateOrderPermission(){
        return hasPermission(ConfigType.CREATE_ORDER);
    }

    public boolean hasVoicePermission(){
        return hasPermission(ConfigType.VOICE);
    }

    public boolean hasPermission(){
        return hasPermission(ConfigType.VOICE);
    }

    public boolean hasDataReportPermission(){
        return hasPermission(ConfigType.DATA_REPORT_MODULE_CODE);
    }

    public boolean hasReceivablePermission(){
        return hasPermission(ConfigType.RECEIVABLE_MODULE_CODE);
    }


    public boolean hasNeedOrderPermission(){
        return hasPermission(ConfigType.HAS_NEED_ORDER);
    }

    public boolean hasPermission(long permission){
        if (sConfigBean==null || sConfigBean.getModules()==null) return false;
        for (Long value:sConfigBean.getModules()){
            if (permission==value){
                return true;
            }
        }
        return false;
    }
}
